package com.teamwe.movecard.repository;

import com.teamwe.movecard.domain.Score;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface ScoreRepository extends CrudRepository<Score, String> {
    /**
     * 获取个人的分数数据
     * @param mpOpenId
     * @return
     */
    public Score getByUserMpOpenId(String mpOpenId);

    /**
     * 查询排行前五的数据
     * @return
     */
    @Query(value = "select * from score  s order by s.score desc limit 5",nativeQuery = true)
    public List<Score> getRankList();

    /**
     * 查询所有人的排行榜，降序
     * @return
     */
    @Query(value = "select * from score  s order by s.score desc",nativeQuery = true)
    public List<Score> getAllListDesc();
}
